/*
 * Resolve.h
 *
 *  Created on: 2011-7-22
 *      Author: gexiao
 */
/*
 * Resolve "constant pool" references into pointers to VM structs.
 */
#ifndef RESOLVE_H_
#define RESOLVE_H_

/*
 * "Direct" and "virtual" methods are stored independently. The type of call
 * used to invoke the method determines which list we search, and whether
 * we travel up into superclasses.
 *
 * (<clinit>,<init>, and methods declared "private" or "static" are stored
 * in the "direct" list. All others are stored in the "virtual" list.)
 */
typedef enum MethodType {
	METHOD_UNKNOWN = 0, METHOD_DIRECT,//<init>,private
	METHOD_STATIC,//static
	METHOD_VIRTUAL,//virtual,super
	METHOD_INTERFACE
//interface
} MethodType;

/*
 * Resolve a class, given the referring class and a constant pool index
 * for the DexTypeId.
 *
 * Does not initialize the class.
 *
 * Throws an exception and returns NULL on failure.
 */
ClassObject* dvmResolveClass(const ClassObject* referrer, u4 classIdx,
		bool fromUnverifiedConstant);

/*
 *
 */
Method* dvmResolveMethod(const ClassObject* referrer, u4 methodIdx,
		MethodType methodType);

/*
 *
 */
Method* dvmResolveInterfaceMethod(const ClassObject* referrer, u4 methodIdx);

/*
 *
 */
InstField* dvmResolveInstField(const ClassObject* referrer, u4 ifieldIdx);

/*
 *
 */
StaticField* dvmResolveStaticField(const ClassObject* referrer, u4 sfieldIdx);

/*
 *
 */
StringObject* dvmResolveString(const ClassObject* referrer, u4 stringIdx);
#endif /* RESOLVE_H_ */
